package com.njmt.cloud.msprovder;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@SpringBootApplication
@RestController
@EnableResourceServer
@EnableAuthorizationServer
@EnableFeignClients(basePackages = "com.njwt.cloud.mscommon.feign.client")
public class MsOauthTokenJwtApplication {

    public static void main(String[] args) {
        SpringApplication.run(MsOauthTokenJwtApplication.class, args);
    }
    @RequestMapping(value = { "/user" }, produces = "application/json")
    public OAuth2Authentication user(OAuth2Authentication user) {
        Map<String, Object> userInfo = new HashMap<>();
        Object details = user.getDetails();
       /* userInfo.put("user", user.getUserAuthentication().getPrincipal());
        userInfo.put("authorities", AuthorityUtils.authorityListToSet(user.getUserAuthentication().getAuthorities()));
       */ return user;
    }                                

}
